using UnityEngine;
using System.Collections;

public class MovePlataform : MonoBehaviour {

	public float minY;
	public float maxY;
	public bool isReady;
	public float speed;
	public bool once;
	private bool readyHide;
	public animWrapMode mode;
	void Update()
	{
		if(isReady)
		{
			
			if(mode.Equals(animWrapMode.TOP))
			{
				float move = transform.localPosition.y + (speed*Time.deltaTime);
				transform.localPosition = new Vector3(transform.localPosition.x,move,transform.localPosition.z);
			}
			if(mode.Equals(animWrapMode.DOWN))
			{
				float move = transform.localPosition.y - (speed*Time.deltaTime);
				transform.localPosition = new Vector3(transform.localPosition.x,move,transform.localPosition.z);
			}
			
			if(transform.localPosition.y >= maxY && mode == animWrapMode.TOP)
			{
				mode = animWrapMode.DOWN;
				if(once)
				{
					isReady = false;
				}
			}
			if(transform.localPosition.y <= minY && mode == animWrapMode.DOWN)
			{
				mode = animWrapMode.TOP;
				if(once)
				{
					isReady = false;
				}
			}
		}
	}
	public enum animWrapMode
	{
		TOP,
		DOWN
	}
}
